package com.hmj.util;

import com.hmj.javabean.MyUser;
import mapper.MyUserMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class MyUserTest {
    SqlSession session;
    MyUserMapper mapper;

    @Before
    public void a(){
        SqlSessionFactory factory = MyBatisUtil.getSqlSessionFactory();
        session = factory.openSession(true);
        mapper=session.getMapper(MyUserMapper.class);

    }
    @After
    public void b(){
        session.close();
    }

    @Test
    public void selectAll(){
        List<MyUser> myUsers = mapper.selectAll();
        for (MyUser myUser : myUsers) {
            System.out.println(myUser);
        }
    }
}
